<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "head.ftl" />
</head>
<body>
<div class="body-box">
<div class="rhead">
	<div class="rpos">当前位置: 菜谱 - 列表</div>
	<form class="ropt">
		<input type="button" value="添加" onclick="location.href='${st.domain}/cook/addOrEdit'"/>
	</form>
	<div class="clear"></div>
</div>
<div style="padding:10px;">
	<div>
	  <form id="search_from">
	  <input type="hidden" id="timeId" name="categoryByTimeId.catId" value="${cook.categoryByTimeId.catId}">
	  <span id="catSelectByTimeId"></span>&nbsp;
  	 <input type="hidden" id="typeId" name="categoryByTypeId.catId" value="${cook.categoryByTypeId.catId}">
	  <span id="catSelectByTypeId"></span>&nbsp;
  	 <input type="hidden" id="styleId" name="categoryByStyleId.catId" value="${cook.categoryByStyleId.catId}">
  		<span id="catSelectByStyleId"></span>&nbsp;
  		<input type="hidden" name="orderType" value="DESC">
  		<select name="orderField">
  			<option value="sort" <#if pi.orderField == "sort">selected</#if>>-默认排序-</option>
  			<option value="addTime" <#if pi.orderField == "addTime">selected</#if>>添加时间</option>
  		</select>
  		<input type="checkbox" name="isRecommend" value="true" <#if cook.isRecommend == true >checked</#if>>推荐&nbsp;
  		<input type="text" name="searchWord" value="${searchWord}" placeholder="关键字"/>
        <input type="submit" value="查找"/>
      </form>
	</div>
	<div class="clear"></div>
</div>
<form id="tableForm" method="post">
<input type="hidden" name="pageNo" value="1"/>
<table class="pn-ltable" style="" width="100%" cellspacing="1" cellpadding="0" border="0">
<thead class="pn-lthead"><tr>
	<th width="20"><input type='checkbox' onclick='Pn.checkbox("ids",this.checked)'/></th>
	<th>ID</th>
	<th>菜谱名称</th>
	<th>类别</th>
	<th>推荐</th>
	<th>添加时间</th>
	<th>操作选项</th></tr></thead>
<tbody  class="pn-ltbody">
<#list cookList as cook>
<tr>
	<td><input type='checkbox' name='ids' value='1'/></td>
	<td>${cook.cookId}</td>
	<td><a href="${st.domain}/cook/addOrEdit?cookId=${cook.cookId}">${cook.name}</a></td>
	<td>${cook.categoryByTimeId.name}-${cook.categoryByTypeId.name}-${cook.categoryByStyleId.name}</td>
	<td><#if cook.isRecommend>推荐</#if>&nbsp;</td>
	<td>${cook.addTime?number_to_datetime}</td>
	<td align="center" style="padding:5px;">
	<select onchange="return operation(this.value);">
		<option value="">-操作-</option>
		<option value="jsonDo('${st.domain}/cook/recommendDo/json?cookId=${cook.cookId}')">推荐</option>
		<option value="jsonDo('${st.domain}/cook/stickDo/json?cookId=${cook.cookId}')">置顶</option>
		<option value="jsonDo('${st.domain}/cook/sinkDo/json?cookId=${cook.cookId}')">沉底</option>
		<option value="location.href='${st.domain}/cook/addOrEdit?cookId=${cook.cookId}'">修改</option>
		<option value="del('${st.domain}/cook/delDo/json?cookId=${cook.cookId}')">删除</option>
	</select>
	</td>
</tr>
</#list>
</tbody>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" class="pn-sp">
	<div id="pageLink" class="pageLinks">${pageLink.linkString}</div>
</td></tr></table>
</form>
</div>
</body>
<script type="text/javascript">
	//用餐时间分类下拉列表
	var timeId = $("#timeId").val();
	$("#catSelectByTimeId").categoryComboBox({
		value: timeId?timeId:203,
		isParentValue: timeId?false:true,
		isLoadParent: false,
		nullText: "-时间分类-",
		onSelect: function(deep, category) {
			$("#timeId").val(category?category.catId:"");
		}
	});
	
	//菜品下拉列表
	var typeId = $("#typeId").val();
	$("#catSelectByTypeId").categoryComboBox({
		value: typeId?typeId:204,
		isParentValue: typeId?false:true,
		isLoadParent: false,
		nullText: "-菜品分类-",
		onSelect: function(deep, category) {
			$("#typeId").val(category?category.catId:"");
		}
	});
	
	// 菜系下拉列表
	var styleId = $("#styleId").val();
	$("#catSelectByStyleId").categoryComboBox({
		value: styleId?styleId:205,
		isParentValue: styleId?false:true,
		isLoadParent: false,
		nullText: "-菜系分类-",
		onSelect: function(deep, category) {
			$("#styleId").val(category?category.catId:"");
		}
	});
	
	function jsonDo(url) {
		$.post(url,{},function(data) {
			if (data.status === 0) {
				pageReload.reload();
			}
		})
		return false;
	}
	 
	// 删除菜谱
	function del(url) {
		if(confirm("确定要删除此菜谱吗?")){
			jsonDo(url);
		}
		return false;
	}
	
	function operation(oper) {
		eval(oper);
		return false;
	}
</script>
</html>